#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
#include<assert.h>

int AddN(int x, int y, int n)
{
	assert(n >= 2 && n <= 10);
	int i = 0;
	int ret = 0;
	int res = 0;
	while ((x > 0 || y > 0) || res == 1)
	{
		int num_x = x % 10;
		int num_y = y % 10;
		int each_num = 0;
		if (num_x + num_y + res >= n)
		{
			each_num = (num_x + num_y) % n + res;
			res = 1;
			if (each_num >= n)
			{
				each_num %= n;
			}
		}
		else
		{
			each_num = num_x + num_y + res;
			res = 0;
		}
		ret += each_num * pow(10, i);
		x /= 10;
		y /= 10;
		i++;
	}
	return ret;
}

int main()
{
	int a = 0;
	int b = 0;
	int N = 0;
	scanf("%d", &N);
	if (N >= 2 && N <= 10)
	{
		scanf("%d %d", &a, &b);
		int ret = AddN(a, b, N);
		printf("ret = %d\n", ret);
	}
	if (N == 16)
	{
		scanf("%x %x", &a, &b);
		int ret = a + b;
		printf("ret = %x\n", ret);
	}
	return 0;
}